package com.itheima.mapper;

import com.itheima.entity.Student;
import com.itheima.entity.StudentParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface StudentMapper {

    /**
     * 分页查询学生信息
     * @param studentParam
     * @return
     */
    List<Student> page(StudentParam studentParam);


    /**
     * 删除数据
     * @param ids
     */
    void delete(Integer[] ids);

    void save(Student student);

    @Select("select * from student where id=#{id}")
    Student getById(Integer id);

    /**
     * 修改学生数据
     * @param student
     */
    void update(Student student);

    /**
     * 添加违纪次数
     * @param id
     * @param score
     */
    @Update("update student set violation_score=#{score},violation_count=violation_count+1 where id=#{id}")
    void add(Integer id, Integer score);
}
